package com.aifast.system.fd.controller;

import com.aifast.common.annotations.AiIdempotent;
import com.aifast.common.base.R;
import com.aifast.common.layui.LayuiDataTable;
import com.aifast.system.fd.entity.FdNation;
import com.aifast.system.fd.service.FdNationService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aifast.common.base.Controller;

import javax.validation.Valid;

/**
 * 民族信息 控制层
 *
 * @author fujian
 * @date 2022-08-05
 */
@RequiredArgsConstructor
@RestController
@RequestMapping("/sys/nation")
public class FdNationController extends Controller
{

    private final FdNationService service;

    @GetMapping("list")
    public LayuiDataTable list() {
        return service.list(get("name"), getPage());
    }

    @AiIdempotent
    @PostMapping("add")
    public R add(@Valid FdNation fdNation) {
        return service.insertOrUpdate(fdNation) ? OK() : ERROR();
    }

    @AiIdempotent
    @GetMapping("del")
    public R del() {
        return service.del(getLong("id"), get("ids")) ? OK() : ERROR();
    }

    @GetMapping("info")
    public R info() {
        return service.info(getLong("id"));
    }

}
